{extend name='common/base'/}
{block name='content'}
<style>
    .field_list_box .form-control{
        height: 38px;
        width: 25%;
        display: inline-block;
        border-color: #ebebeb;
        -webkit-border-radius: 2px;
        border-radius: 2px;
        color: #8b95a5;
        padding: 5px 12px;
        line-height: inherit;
        -webkit-transition: 0.2s linear;
        transition: 0.2s linear;
        -webkit-box-shadow: none;
        box-shadow: none;
    }
    .form-group button[type='submit']{
        margin-top: 35px;
    }
</style>
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <ul class="nav nav-tabs page-tabs" role="tablist">
                {foreach $site_list as $k=>$v}
                <li role="presentation" class="{$v.active?'active':''}"><a href="#{$v.name}" aria-controls="{$v.name}" role="tab" data-toggle="tab">{$v.title}</a></li>
                {/foreach}
                <li role="presentation"><a href="#add" aria-controls="add" role="tab" data-toggle="tab" title="添加"><i
                        class="fa fa-plus"></i></a></li>
            </ul>
            <div class="tab-content">
                {foreach $site_list as $k=>$v}
                <div class="tab-pane fade in {$v.active?'active':''}" role="tabpanel" id="{$v.name}">
                    <form action="{:url('webconfig_webconfig_edit')}" role="form" method="post" id="form-{$v.name}" name="edit-form" class="edit-form">
                        {foreach $v['list'] as $key=>$value}
                            <div class="form-group">
                                <label class="control-label">{$value.title}</label>
                                <div class="form-item">
                                {switch $value.type}
                                {case string|number}
                                <input class="form-control" type="{$value.type=='string'?'text':'number'}" name="row[{$value.name}]"
                                       value="{$value.value}" data-rule="{$value.rule}" data-tip="{$value.tip}" placeholder="{$value.tip}">
                                {/case}
                                {case date|datetime|time}
                                <input class="form-control datetimepicker"  data-rule="{$value.rule}" data-tip="{$value.tip}" {if $value.type=='date'} data-date-format="YYYY-MM-DD" {elseif $value.type=='time' } data-date-format="HH:mm:ss" {else} data-date-format="YYYY-MM-DD HH:mm:ss" {/if} type="text" name="row[{$value.name}]"
                                       value="{$value.value}" data-rule="{$value.rule}" data-tip="{$value.tip}" placeholder="{$value.tip}">
                                {/case}
                                {case text}
                                <textarea name="row[{$value.name}]" data-rule="{$value.rule}" data-tip="{$value.tip}" placeholder="{$value.tip}"  cols="30" rows="5" class="form-control">{$value.value}</textarea>
                                {/case}
                                {case array}
                                <div class="field_list_box"  style="width: 50%" data-name="row[{$value.name}]">
                                    <button type="button" data-clone-class="field_list_box_item" data-append-class="field_list_box" class="btn btn-info btn-sm btn-clone"><i class="fa fa-plus">追加</i></button>
                                    <textarea name="row[{$value.name}]" data-name="row[{$value.name}]" data-field-box="field_list_box" class="form-control hide field_list" cols="30" rows="5">{$value.value}</textarea>
                                </div>
                                {/case}
                                {case radio}
                                    {foreach $value.content as $k=>$v}
                                    <label class="lyear-radio radio-inline radio-primary" for="row[{$value.name}]-{$k}">
                                        <input type="radio"  data-rule="{$value.rule}" data-tip="{$value.tip}" name="row[{$value.name}]" id="row[{$value.name}]-{$k}"
                                       {in name="k" value="$value.value" } checked {/in}><span>{$v}</span>
                                    </label>
                                    {/foreach}
                                {/case}
                                {case checkbox}
                                {foreach $value.content as $k=>$v}
                                <label class="lyear-checkbox checkbox-inline checkbox-success" for="row[{$value.name}]-{$k}">
                                    <input type="checkbox" data-rule="{$value.rule}" data-tip="{$value.tip}" name="row[{$value.name}][]" id="row[{$value.name}]-{$k}"
                                           {in name="k" value="$value.value" } checked {/in}><span>{$v}</span>
                                </label>
                                {/foreach}
                                {/case}
                                {case switch}
                                    <label class="lyear-switch switch-outline switch-info">
                                        <input type="checkbox"  data-rule="{$value.rule}" data-tip="{$value.tip}" value="1" name="row[{$value.name}]" {in name="1" value="$value.value"} checked {/in}">
                                        <span></span>
                                    </label>
                                {/case}
                                {case select|selects}
                                    <select name="row[{$value.name}]{if $value.type=='selects'}[]{/if}"  data-rule="{$value.rule}" data-tip="{$value.tip}" {if $value.type=='selects'} multiple {/if} class="form-control selectpicker" id="row[$value.name]-{$key}">
                                        {foreach $value.content as $k=>$v}
                                        <option value="{$k}">{$v}</option>
                                        {/foreach}
                                    </select>
                                {/case}
                                {case file|image}
                                    <button type="button" class="btn btn-sm btn-danger webupload" id="{$value.type}_{$value.name}_{$key}"
                                            data-input-id="c-{$value.name}-{$key}"
                                            data-preview-id="p-{$value.name}-{$key}">{$value.title}
                                    </button>
                                    <input type="hidden" name="row[{$value.name}]" id="c-{$value.name}-{$key}" value="{$value.value}">
                                    <ul class="list-inline clearfix lyear-uploads-pic" id="p-{$value.name}-{$key}">
                                    </ul>
                                {/case}
                                {case files|images}
                                <button type="button" class="btn btn-sm btn-danger webupload" id="{$value.type}_{$value.name}_{$key}"
                                        data-input-id="c-{$value.name}-{$key}"
                                        data-preview-id="p-{$value.name}-{$key}" data-multiple="true">{$value.title}
                                </button>
                                <input type="hidden" name="row[{$value.name}]" id="c-{$value.name}-{$key}" value="{$value.value}">
                                <ul class="list-inline clearfix lyear-uploads-pic" id="p-{$value.name}-{$key}">
                                </ul>
                                {/case}
                                {/switch}
                                </div>
                            </div>
                        {/foreach}
                        <div class="form-group" style="margin-top: 15px">
                            <button type="submit" class="btn btn-primary m-r-5">确 定</button>
                        </div>
                    </form>
                </div>
                {/foreach}
                <!--添加-->
                <div class="tab-pane fade in" role="tabpanel" id="add">
                    <form action="{:url('webconfig_webconfig_add')}" method="post" id="add-form" role="form" class="add-form">
                        <div class="form-group">
                            <label >类型</label>
                            <select name="row[type]" class="form-control selectpicker">
                                {foreach $type_list as $k=>$v}
                                <option value="{$k}">{$v}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group">
                            <label >分组</label>
                            <select name="row[group]" class="form-control selectpicker">
                                {foreach $group_list as $k=>$v}
                                <option value="{$k}">{$v}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group">
                            <label >变量名</label>
                            <input type="text" class="form-control" id="name" name="row[name]" value=""
                                   aria-invalid="true">
                        </div>
                        <div class="form-group">
                            <label >变量标题</label>

                            <input type="text" class="form-control" id="title" name="row[title]" value="">
                        </div>
                        <div class="form-group">
                            <label >变量值</label>
                            <input type="text" class="form-control" id="value" name="row[value]" value="" data-rule="">
                        </div>
                        <div class="form-group hide" id="add-content-container">
                            <label >数据列表</label>
                            <textarea name="row[content]" id="content" cols="30" rows="5" class="form-control" placeholder="title1|value1,title2|value2"></textarea>
                        </div>
                        <div class="form-group">
                            <label >提示信息</label>
                            <input type="text" class="form-control" id="tip" name="row[tip]" value="" data-rule="">
                        </div>
                        <div class="form-group">
                            <label for="web_site_logo">校验规则</label>
                            <div class="input-group">
                                <div class="input-group-btn dropup">
                                    <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                            aria-haspopup="true" aria-expanded="false" type="button">规则选择<span
                                            class="caret"></span></button>
                                    <ul class="dropdown-menu" style="cursor: pointer">
                                        {foreach $rule_list as $k=>$v}
                                        <li><a data-value="{$k}" href="javascript:;">{$v}（{$k}）</a></li>
                                        {/foreach}
                                    </ul>
                                </div>
                                <input class="form-control" type="text" id="rule" readonly name="row[rule]"
                                       placeholder="添加标签" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label >扩展属性</label>
                            <textarea name="row[extend]" placeholder="扩展属性支持{id}、{name}、{group}、{title}、{value}、{content}、{rule}替换" id="extend" cols="30" rows="5" class="form-control"></textarea>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary m-r-5">确 定</button>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>

</div>
{/block}
